/*
 * Created on Dec 21, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.vectrics.recruiter.user.resume;

import java.util.Collection;
import java.util.Iterator;
import org.apache.log4j.Logger;
import org.vectrics.domain.Domain;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.user.Resume;

/**
 * @author MMoore
 */
public class ResumeExpireBatchRunnable implements Runnable {
	private transient Logger log = Logger.getLogger(this.getClass());
	private Domain domain = null;

	public ResumeExpireBatchRunnable(Domain domain) {
		this.domain = domain;
	}
	
	public void run() {
		log.debug("Running batch job: Resume Expire Batch");
		boolean done = false;
		while (!done) {
			Collection expiredResumes = RecruitServiceLocator.getRecruitUserService().findResumesThatHaveExpired(domain, 0, 9);
			if (expiredResumes.size() == 0) {
				done = true;
			}
			Iterator iter = expiredResumes.iterator();
			while (iter.hasNext()) {
				Resume resume = (Resume)iter.next();
				resume.setVoided(true);
				RecruitServiceLocator.getRecruitUserService().updateResume(resume);
			}
		}
		log.debug("Finished Running batch job: Resume Expire Batch");
	}

}
